@@ -16,7 +16,6 @@ angular.module('codexApp.index', [])
|
||
| 16 | 16 |
var page_count_start = 30; |
| 17 | 17 |
var info_count = 0; |
| 18 | 18 |
var loaded = false; |
| 19 |
- var view_changing = true; |
|
| 20 | 19 |
$scope.files = []; |
| 21 | 20 |
|
| 22 | 21 |
$scope.setView = function() {
|
@@ -59,23 +58,62 @@ angular.module('codexApp.index', [])
|
||
| 59 | 58 |
} |
| 60 | 59 |
$scope.files = f; |
| 61 | 60 |
all_files.splice(0, i); |
| 62 |
- var info = all_files.length + " Files" |
|
| 61 |
+ var info = info_count + " Files" |
|
| 63 | 62 |
$rootScope.$broadcast('footer:info', info);
|
| 64 | 63 |
break; |
| 65 | 64 |
case "Notebooks": |
| 66 | 65 |
$scope.current_folder = FileService.getNotesDir(); |
| 67 |
- $scope.files = FileService.getFolders(); |
|
| 68 |
- var info = $scope.files.length + " Notebooks" |
|
| 66 |
+ var note = { type : "Notebooks" }
|
|
| 67 |
+ FileService.setCurrentNote(note); |
|
| 68 |
+ all_files = FileService.getFolders(); |
|
| 69 |
+ info_count = all_files.length; |
|
| 70 |
+ var f = []; |
|
| 71 |
+ var i = 0; |
|
| 72 |
+ for (i = 0; i <= page_count_start; i++) {
|
|
| 73 |
+ if(all_files[i] != undefined){
|
|
| 74 |
+ f.push(all_files[i]) |
|
| 75 |
+ } else {
|
|
| 76 |
+ break; |
|
| 77 |
+ } |
|
| 78 |
+ } |
|
| 79 |
+ $scope.files = f; |
|
| 80 |
+ all_files.splice(0, i); |
|
| 81 |
+ var info = info_count + " Folders" |
|
| 69 | 82 |
$rootScope.$broadcast('footer:info', info);
|
| 70 | 83 |
break; |
| 71 | 84 |
case "Notebook": |
| 72 |
- $scope.files = FileService.getFiles(FileService.getCurrentNote().path); |
|
| 73 |
- var info = $scope.files.length + " Items" |
|
| 85 |
+ $scope.current_folder = FileService.getNotesDir(); |
|
| 86 |
+ all_files = FileService.getFiles(FileService.getCurrentNote().path); |
|
| 87 |
+ info_count = all_files.length; |
|
| 88 |
+ var f = []; |
|
| 89 |
+ var i = 0; |
|
| 90 |
+ for (i = 0; i <= page_count_start; i++) {
|
|
| 91 |
+ if(all_files[i] != undefined){
|
|
| 92 |
+ f.push(all_files[i]) |
|
| 93 |
+ } else {
|
|
| 94 |
+ break; |
|
| 95 |
+ } |
|
| 96 |
+ } |
|
| 97 |
+ $scope.files = f; |
|
| 98 |
+ all_files.splice(0, i); |
|
| 99 |
+ var info = info_count + " Items" |
|
| 74 | 100 |
$rootScope.$broadcast('footer:info', info);
|
| 75 | 101 |
break; |
| 76 | 102 |
case "Searched Files": |
| 77 |
- $scope.files = FileService.getSearchFiles(); |
|
| 78 |
- var info = $scope.files.length + " Items" |
|
| 103 |
+ all_files = FileService.getSearchFiles(); |
|
| 104 |
+ info_count = all_files.length; |
|
| 105 |
+ var f = []; |
|
| 106 |
+ var i = 0; |
|
| 107 |
+ for (i = 0; i <= page_count_start; i++) {
|
|
| 108 |
+ if(all_files[i] != undefined){
|
|
| 109 |
+ f.push(all_files[i]) |
|
| 110 |
+ } else {
|
|
| 111 |
+ break; |
|
| 112 |
+ } |
|
| 113 |
+ } |
|
| 114 |
+ $scope.files = f; |
|
| 115 |
+ all_files.splice(0, i); |
|
| 116 |
+ var info = info_count + " Items" |
|
| 79 | 117 |
$rootScope.$broadcast('footer:info', info);
|
| 80 | 118 |
break; |
| 81 | 119 |
} |
@@ -90,12 +128,11 @@ angular.module('codexApp.index', [])
|
||
| 90 | 128 |
} else {
|
| 91 | 129 |
$location.hash('grid');
|
| 92 | 130 |
} |
| 93 |
- $location.hash('grid');
|
|
| 94 |
- $anchorScroll(); |
|
| 95 | 131 |
$timeout(function() {
|
| 132 |
+ console.log("Fading in new items")
|
|
| 96 | 133 |
$scope.fader = "fade-in"; |
| 97 | 134 |
loaded = true; |
| 98 |
- view_changing = false; |
|
| 135 |
+ $anchorScroll(); |
|
| 99 | 136 |
}, 250); |
| 100 | 137 |
}, 25); |
| 101 | 138 |
} |
@@ -103,21 +140,13 @@ angular.module('codexApp.index', [])
|
||
| 103 | 140 |
$scope.setView(); |
| 104 | 141 |
|
| 105 | 142 |
$rootScope.$on('window-view:change', function(){
|
| 106 |
- if(view_changing == false){
|
|
| 107 |
- view_changing = true |
|
| 108 |
- console.log("Changin view...");
|
|
| 109 |
- current_page = 1; |
|
| 110 |
- loaded = false; |
|
| 111 |
- $scope.fader = "fade-out"; |
|
| 112 |
- |
|
| 113 |
- var state = FileService.getCurrentNote(); |
|
| 114 |
- if(state.type == "All Notes" || state.type == "All Files" || state.type == "Folder"){
|
|
| 115 |
- $scope.setView(); |
|
| 116 |
- } else {
|
|
| 117 |
- $timeout(function() {
|
|
| 118 |
- $state.go($state.current, {}, {reload: true});
|
|
| 119 |
- }, 200); |
|
| 120 |
- } |
|
| 143 |
+ current_page = 1; |
|
| 144 |
+ loaded = false; |
|
| 145 |
+ console.log("Changin view...");
|
|
| 146 |
+ $scope.fader = "fade-out"; |
|
| 147 |
+ var state = FileService.getCurrentNote(); |
|
| 148 |
+ if(state.type == "All Files" || state.type == "All Notes" || state.type == "Notebooks" || state.type == "Notebook" || state.type == "Searched Files"){
|
|
| 149 |
+ $scope.setView(); |
|
| 121 | 150 |
} |
| 122 | 151 |
}); |
| 123 | 152 |
|
@@ -133,6 +162,7 @@ angular.module('codexApp.index', [])
|
||
| 133 | 162 |
break; |
| 134 | 163 |
case "Folder": |
| 135 | 164 |
$scope.current_folder = file.path; |
| 165 |
+ var file = { type : "Notebook", path : file.path }
|
|
| 136 | 166 |
FileService.setCurrentNote(file) |
| 137 | 167 |
PrefsService.setCurrentView("Notebook");
|
| 138 | 168 |
$scope.setView(); |
@@ -247,7 +277,8 @@ angular.module('codexApp.index', [])
|
||
| 247 | 277 |
|
| 248 | 278 |
$scope.infiniteScroll = function() {
|
| 249 | 279 |
if(loaded == true){
|
| 250 |
- if (FileService.getCurrentNote().type == "All Notes" || FileService.getCurrentNote().type == "All Files"){
|
|
| 280 |
+ var note_type = FileService.getCurrentNote().type; |
|
| 281 |
+ if (note_type == "All Notes" || note_type == "All Files" || note_type == "Notebooks" || note_type == "Notebook"){
|
|
| 251 | 282 |
if(all_files.length > 0 && $scope.files.length < info_count){
|
| 252 | 283 |
current_page = current_page + 1; |
| 253 | 284 |
console.log("scrolling")
|
@@ -32,6 +32,7 @@ angular.module('codexApp.noteView', [])
|
||
| 32 | 32 |
|
| 33 | 33 |
|
| 34 | 34 |
$scope.loadNoteView = function() {
|
| 35 |
+ console.log($scope.note.path); |
|
| 35 | 36 |
filesystem.readFile($scope.note.path, function(err, data) {
|
| 36 | 37 |
|
| 37 | 38 |
//$scope.note.data = String.fromCharCode.apply(null, data); |
@@ -90,7 +91,10 @@ angular.module('codexApp.noteView', [])
|
||
| 90 | 91 |
$rootScope.$on('note-view:reload', function() {
|
| 91 | 92 |
$scope.note = FileService.getCurrentNote(); |
| 92 | 93 |
$scope.html_data = ""; |
| 93 |
- $scope.loadNoteView(); |
|
| 94 |
+ if($scope.note.path != undefined){
|
|
| 95 |
+ $scope.loadNoteView(); |
|
| 96 |
+ } |
|
| 97 |
+ |
|
| 94 | 98 |
}); |
| 95 | 99 |
|
| 96 | 100 |
$scope.fixImgURLs = function(current_note_path, html){
|
@@ -31,7 +31,6 @@ angular.module('codexApp.sidebar', [])
|
||
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
$scope.goToNotebooks = function() {
|
| 34 |
- FileService.setCurrentNote(FileService.getNote(FileService.getNotesDir())); |
|
| 35 | 34 |
PrefsService.setCurrentView("Notebooks");
|
| 36 | 35 |
$scope.activateSidebarBtn(2); |
| 37 | 36 |
$rootScope.$broadcast('main-window:file-list');
|
@@ -7,6 +7,12 @@ angular.module('codexApp')
|
||
| 7 | 7 |
var notes_dir = ""; |
| 8 | 8 |
var searched_files = []; |
| 9 | 9 |
var recent_file_views = []; |
| 10 |
+ var default_notes_dir = "/codex/inbox"; |
|
| 11 |
+ var default_home_note = "/codex/index.md" |
|
| 12 |
+ var notes = []; |
|
| 13 |
+ var current_note = ""; |
|
| 14 |
+ var note_history = []; |
|
| 15 |
+ var note_history_index = 0; |
|
| 10 | 16 |
|
| 11 | 17 |
var getAppData = function(){
|
| 12 | 18 |
if(notes_dir === ""){
|
@@ -63,17 +69,6 @@ angular.module('codexApp')
|
||
| 63 | 69 |
} |
| 64 | 70 |
} |
| 65 | 71 |
|
| 66 |
- getAppData(); |
|
| 67 |
- console.log("-> Loading content from folder: " + appData.UserDataDirectory);
|
|
| 68 |
- |
|
| 69 |
- |
|
| 70 |
- var default_notes_dir = "/codex/inbox"; |
|
| 71 |
- var default_home_note = "/codex/index.md" |
|
| 72 |
- var notes = []; |
|
| 73 |
- var current_note = ""; |
|
| 74 |
- var note_history = []; |
|
| 75 |
- var note_history_index = 0; |
|
| 76 |
- |
|
| 77 | 72 |
var prettySize = function(bytes) {
|
| 78 | 73 |
if (bytes <= 1024) {
|
| 79 | 74 |
return bytes + " KB" |
@@ -100,6 +95,10 @@ angular.module('codexApp')
|
||
| 100 | 95 |
return "Image"; |
| 101 | 96 |
case "png": |
| 102 | 97 |
return "Image"; |
| 98 |
+ case "gif": |
|
| 99 |
+ return "Image"; |
|
| 100 |
+ case "jpeg": |
|
| 101 |
+ return "Image"; |
|
| 103 | 102 |
case "md": |
| 104 | 103 |
return "Markdown"; |
| 105 | 104 |
case 'dir': |
@@ -143,11 +142,13 @@ angular.module('codexApp')
|
||
| 143 | 142 |
var getThumbnail = function(file_path) {
|
| 144 | 143 |
var type = getFileType(file_path); |
| 145 | 144 |
var thumbs = appData.thumbs |
| 145 |
+ //console.log("Thumbs data:")
|
|
| 146 |
+ //console.log(thumbs) |
|
| 146 | 147 |
switch (type) {
|
| 147 | 148 |
case "Markdown": |
| 148 | 149 |
var thumb = "" |
| 149 | 150 |
for (var i=0; i < thumbs.length; i++) {
|
| 150 |
- if (thumbs[i].file === file_path) {
|
|
| 151 |
+ if (thumbs[i].file == file_path) {
|
|
| 151 | 152 |
thumb = thumbs[i].path; |
| 152 | 153 |
break; |
| 153 | 154 |
} |
@@ -156,7 +157,7 @@ angular.module('codexApp')
|
||
| 156 | 157 |
// [ ] Thumbnail generation queue |
| 157 | 158 |
// [ ] Default thumbnail |
| 158 | 159 |
console.log("> NO THUMBNAIL FOUND! GENERATING NEW ONE")
|
| 159 |
- thumb = saveThumbnail(file_path); |
|
| 160 |
+ //thumb = saveThumbnail(file_path); |
|
| 160 | 161 |
} |
| 161 | 162 |
return thumb |
| 162 | 163 |
default: |
@@ -223,7 +224,7 @@ angular.module('codexApp')
|
||
| 223 | 224 |
|
| 224 | 225 |
var getAllFilesFromFolder = function(dir) {
|
| 225 | 226 |
if (typeof(dir)==='undefined') dir = notes_dir; |
| 226 |
- console.log("Loading file list for " + dir)
|
|
| 227 |
+ //console.log("Loading file list for " + dir)
|
|
| 227 | 228 |
var results = searchRecentFileViews(dir); |
| 228 | 229 |
if(results === undefined){
|
| 229 | 230 |
results = listAllFilesFromFolder(dir) |
@@ -237,6 +238,22 @@ angular.module('codexApp')
|
||
| 237 | 238 |
return results; |
| 238 | 239 |
}; |
| 239 | 240 |
|
| 241 |
+ var getFilesFromFolder = function(dir) {
|
|
| 242 |
+ //if (typeof(dir)==='undefined') dir = notes_dir; |
|
| 243 |
+ // var results = searchRecentFileViews(dir); |
|
| 244 |
+ // if(results === undefined){
|
|
| 245 |
+ // results = listFilesFromFolder(dir) |
|
| 246 |
+ // var history = {"dir" : dir, "files" : results }
|
|
| 247 |
+ // recent_file_views.push(history); |
|
| 248 |
+ // console.log("Saved " + history.files.length + " files...")
|
|
| 249 |
+ // } else {
|
|
| 250 |
+ // console.log("Loading " + results.length + " files...")
|
|
| 251 |
+ // } |
|
| 252 |
+ results = listFilesFromFolder(dir) |
|
| 253 |
+ $rootScope.$broadcast('file-service:files-loaded');
|
|
| 254 |
+ return results; |
|
| 255 |
+ }; |
|
| 256 |
+ |
|
| 240 | 257 |
var listAllFilesFromFolder = function(dir){
|
| 241 | 258 |
var filesystem = require("fs");
|
| 242 | 259 |
var results = []; |
@@ -256,6 +273,21 @@ angular.module('codexApp')
|
||
| 256 | 273 |
return results; |
| 257 | 274 |
} |
| 258 | 275 |
|
| 276 |
+ var listFilesFromFolder = function(dir){
|
|
| 277 |
+ var filesystem = require("fs");
|
|
| 278 |
+ var results = []; |
|
| 279 |
+ filesystem.readdirSync(dir).forEach(function(file) {
|
|
| 280 |
+ file_path = dir+'/'+file; |
|
| 281 |
+ var stat = filesystem.statSync(file_path); |
|
| 282 |
+ if(isValidFile(file)) {
|
|
| 283 |
+ var jsonData = {};
|
|
| 284 |
+ var file_obj = SetFileInfo(jsonData, dir, file_path, stat) |
|
| 285 |
+ results.push(file_obj); |
|
| 286 |
+ } |
|
| 287 |
+ }); |
|
| 288 |
+ return results; |
|
| 289 |
+ } |
|
| 290 |
+ |
|
| 259 | 291 |
var searchRecentFileViews = function(dir){
|
| 260 | 292 |
for (var i = 0; i < recent_file_views.length; i++) {
|
| 261 | 293 |
if(recent_file_views[i].dir == dir){
|
@@ -533,7 +565,7 @@ angular.module('codexApp')
|
||
| 533 | 565 |
note_history.push(current_note); |
| 534 | 566 |
note_history_index = note_history.length -1; |
| 535 | 567 |
|
| 536 |
- console.log(current_note); |
|
| 568 |
+ //console.log(current_note); |
|
| 537 | 569 |
//console.log("Current_note: " + current_note.title)
|
| 538 | 570 |
} |
| 539 | 571 |
|
@@ -592,6 +624,9 @@ angular.module('codexApp')
|
||
| 592 | 624 |
case "Folder": |
| 593 | 625 |
$state.go("index");
|
| 594 | 626 |
break; |
| 627 |
+ case "Notebook": |
|
| 628 |
+ $state.go("index");
|
|
| 629 |
+ break; |
|
| 595 | 630 |
case "Image": |
| 596 | 631 |
$state.go("image-view");
|
| 597 | 632 |
break; |
@@ -630,4 +665,7 @@ angular.module('codexApp')
|
||
| 630 | 665 |
return searched_files; |
| 631 | 666 |
} |
| 632 | 667 |
|
| 668 |
+ getAppData(); |
|
| 669 |
+ console.log("-> Loading content from folder: " + appData.UserDataDirectory);
|
|
| 670 |
+ |
|
| 633 | 671 |
}]) |
@@ -72,6 +72,10 @@ |
||
| 72 | 72 |
width: 1000px; |
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 |
+.note .width-fit {
|
|
| 76 |
+ width: 100%; |
|
| 77 |
+} |
|
| 78 |
+ |
|
| 75 | 79 |
.note>h1:first-of-type {
|
| 76 | 80 |
margin-top: 0px; |
| 77 | 81 |
} |
@@ -139,11 +143,15 @@ a {
|
||
| 139 | 143 |
|
| 140 | 144 |
pre code.hljs {
|
| 141 | 145 |
display: block; |
| 142 |
- line-height: 2em; |
|
| 146 |
+ line-height: 1.0em; |
|
| 143 | 147 |
border-radius: 5px; |
| 144 | 148 |
padding-left: 8px; |
| 145 | 149 |
padding-right: 8px; |
| 150 |
+ padding-top: 8px; |
|
| 151 |
+ padding-bottom: 8px; |
|
| 152 |
+ font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; |
|
| 146 | 153 |
} |
| 154 |
+ |
|
| 147 | 155 |
code.hljs {
|
| 148 | 156 |
display: inline-flex; |
| 149 | 157 |
padding: 2px; |
@@ -202,6 +210,7 @@ code.hljs .hljs-title {
|
||
| 202 | 210 |
|
| 203 | 211 |
.icon-name {
|
| 204 | 212 |
width: 220px; |
| 213 |
+ overflow-wrap: break-word; |
|
| 205 | 214 |
} |
| 206 | 215 |
|
| 207 | 216 |
.notebook-icon-title {
|
@@ -250,3 +259,37 @@ code.hljs .hljs-title {
|
||
| 250 | 259 |
/* bring your own prefixes */ |
| 251 | 260 |
transform: translate(-50%, -50%); |
| 252 | 261 |
} |
| 262 |
+ |
|
| 263 |
+.column3 {
|
|
| 264 |
+ width: 30%; |
|
| 265 |
+ margin-right: 3%; |
|
| 266 |
+ float: left; |
|
| 267 |
+} |
|
| 268 |
+ |
|
| 269 |
+.column3 img {
|
|
| 270 |
+ width: 100%; |
|
| 271 |
+} |
|
| 272 |
+ |
|
| 273 |
+.clear-fix {
|
|
| 274 |
+ clear: both; |
|
| 275 |
+} |
|
| 276 |
+ |
|
| 277 |
+figure {
|
|
| 278 |
+ -webkit-margin-before: 0em; |
|
| 279 |
+ -webkit-margin-after: 0em; |
|
| 280 |
+ -webkit-margin-start: 0px; |
|
| 281 |
+ -webkit-margin-end: 0px; |
|
| 282 |
+} |
|
| 283 |
+ |
|
| 284 |
+blockquote {
|
|
| 285 |
+ padding: 5px 20px; |
|
| 286 |
+ margin: 0 0 20px; |
|
| 287 |
+ font-size: 17.5px; |
|
| 288 |
+ border-left: 5px solid #eee; |
|
| 289 |
+} |
|
| 290 |
+ |
|
| 291 |
+blockquote p {
|
|
| 292 |
+ margin-top: 2px; |
|
| 293 |
+ margin-bottom: 2px; |
|
| 294 |
+ font-style: italic; |
|
| 295 |
+} |